<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #div1 {
            width: 100px;
            height: 100px;
            background-color: rgb(12, 12, 205);
            position: absolute;
            transition: all 0.5s;

            /* display: inline-block; */
            /* left: 500px; */
        }

        #div2 {
            width: 100px;
            height: 100px;
            background-color: rgb(255, 0, 0);
            position: absolute;
            transition: all 0.5s;

            /* display: inline-block; */
            /* left: 300px; */
        }

        button {
            width: 100px;
            height: 50px;

        }
    </style>
</head>

<body>
    <div id="div1" style="left: 1000px;"></div>
    <div id="div2" style="left: 300px;"></div>
    <button id="jh">交换</button>
    <script>
        let jhs = document.getElementById("jh");
        let div1s = document.getElementById("div1");
        let div2s = document.getElementById("div2");

        jhs.onmousedown = function () {
            let a = div1s.style.left;
            let b = div2s.style.left;
            console.log(a);
            console.log(b);
            console.log("测试");
            div1s.style.left = b;
            div2s.style.left = a;
        }
        
    </script>
</body>

</html>